package org.linloong.modules.apis.monitor.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Data
@TableName("t_audio_pattern_data")
@Schema(name = "AudioPatternData", description = "声纹数据实体（对应文档\"声纹数据接口\"章节Response）")
public class AudioPatternData {
    @TableId(type = IdType.ASSIGN_UUID)
    @Schema(description = "自定义主键（UUID）", example = "123e4567-e89b-12d3-a456-426614174008")
    private String id;

    @Schema(description = "文档中返回的\"id\"字段（无实际意义，备用）", example = "eeqrghnerhnjionarto")
    private String apiId;

    @Schema(description = "设备ID（仅声纹设备）", example = "ZW202404") // 文档2.6版本新增声纹接口
    private String deviceId;

    @Schema(description = "系统时间戳（文档中\"timestamp\"字段，Unix毫秒级）", example = "1592271960000")
    private Long timestamp;

    @Schema(description = "识别最佳物种名称（文档中\"recogAnimalName\"字段）", example = "小鹀")
    private String recogAnimalName;

    @Schema(description = "数据采集时间（文档中\"collectionTime\"字段）", example = "2021-11-23 13:37:58")
    private String collectionTime;

    @Schema(description = "数据创建时间（文档中\"createTime\"字段，可为NULL）", example = "2021-11-23 13:38:00")
    private String createTime;

    @Schema(description = "声纹数据地址（文档中\"recogSoundUrl\"字段）", example = "https://oss.example.com/audio/1.mp3")
    private String recogSoundUrl;

    @Schema(description = "声谱图地址（文档中\"recogSpectUrl\"字段）", example = "https://oss.example.com/spect/1.jpg")
    private String recogSpectUrl;

    @Schema(description = "数据接收时间（文档中\"receiveTime\"字段）", example = "2021-11-23 13:38:05")
    private String receiveTime;

    @Schema(description = "识别ID（文档中\"recogID\"字段）", example = "REC20211123001")
    private String recogID;

    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "识别物种前5（文档中\"animals\"数组，含name/score字段）")
    private List<Animal> animals;

    /**
     * 识别物种子模型（文档"声纹数据接口"章节animals字段）
     */
    @Data
    @Schema(name = "Animal", description = "识别物种子实体（文档\"声纹数据接口\"章节animals数组）")
    public static class Animal {
        @Schema(description = "物种名称", example = "小鹀")
        private String name;

        @Schema(description = "匹配分数（0-1）", example = "0.979")
        private Float score;
    }
}